package com.zlt.bkparking.service.impl;

import com.zlt.bkparking.entity.AdvertisingEquipment;
import com.zlt.bkparking.entity.AdvertisingEquipmentExample;
import com.zlt.bkparking.mapper.AdvertisementMapper;
import com.zlt.bkparking.mapper.AdvertisingEquipmentMapper;
import com.zlt.bkparking.service.AdvertisingEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: hzj
 * @Description:
 */
@Service
public class AdvertisingEquipmentServiceImpl implements AdvertisingEquipmentService {

    @Autowired
    private AdvertisingEquipmentMapper advertisingEquipmentMapper;

    @Autowired
    private AdvertisementMapper advertisementMapper;

    @Override
    public List<Long> getAdvertisementByEquipmentId(Integer id) {
        AdvertisingEquipmentExample example = new AdvertisingEquipmentExample();
        example.createCriteria().andEIdEqualTo(id);
        List<AdvertisingEquipment> advertisingEquipments = advertisingEquipmentMapper.selectByExample(example);
        return  advertisingEquipments.stream().map(AdvertisingEquipment::getAdId).collect(Collectors.toList());


    }

    public List<AdvertisingEquipment> getEquipmentIdByAdId(Long AdId){
        AdvertisingEquipmentExample example = new AdvertisingEquipmentExample();
        example.createCriteria().andAdIdEqualTo(AdId);
        return advertisingEquipmentMapper.selectByExample(example);
    }
}
